package com.jh.user.pojo.freeQuick;

import cn.jh.common.utils.Constss;
import cn.jh.common.utils.ResultWrap;

import java.io.Serializable;
import java.util.Map;
import java.util.Objects;

import static com.google.common.base.Strings.isNullOrEmpty;

/**
 * @author Yichuan
 * @version 1.0
 */
public class BankCardDTO implements Serializable {

    private static final long serialVersionUID = -8824741698014040551L;

    private String bankAccountName;
    private String cardNo;
    private String bankName;
    private String bankAbbr;
    private String idCard;
    private String phone;
    private String bankAccountType;
    private String bankSubName;
    private String bankChannelNo;
    private String bankCardProvince;
    private String bankCardCity;
    private String bankCardType;
    private String cvn2;
    private String period;
    private String defaulted = "0";

    public BankCardDTO() {
    }

    public String getBankAccountName() {
        return bankAccountName;
    }

    public void setBankAccountName(String bankAccountName) {
        this.bankAccountName = bankAccountName;
    }

    public String getCardNo() {
        return cardNo;
    }

    public void setCardNo(String cardNo) {
        this.cardNo = cardNo;
    }

    public String getBankName() {
        return bankName;
    }

    public void setBankName(String bankName) {
        this.bankName = bankName;
    }

    public String getBankAbbr() {
        return bankAbbr;
    }

    public void setBankAbbr(String bankAbbr) {
        this.bankAbbr = bankAbbr;
    }

    public String getIdCard() {
        return idCard;
    }

    public void setIdCard(String idCard) {
        this.idCard = idCard;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getBankAccountType() {
        return bankAccountType;
    }

    public void setBankAccountType(String bankAccountType) {
        this.bankAccountType = bankAccountType;
    }

    public String getBankSubName() {
        return bankSubName;
    }

    public void setBankSubName(String bankSubName) {
        this.bankSubName = bankSubName;
    }

    public String getBankChannelNo() {
        return bankChannelNo;
    }

    public void setBankChannelNo(String bankChannelNo) {
        this.bankChannelNo = bankChannelNo;
    }

    public String getBankCardProvince() {
        return bankCardProvince;
    }

    public void setBankCardProvince(String bankCardProvince) {
        this.bankCardProvince = bankCardProvince;
    }

    public String getBankCardCity() {
        return bankCardCity;
    }

    public void setBankCardCity(String bankCardCity) {
        this.bankCardCity = bankCardCity;
    }

    public String getBankCardType() {
        return bankCardType;
    }

    public void setBankCardType(String bankCardType) {
        this.bankCardType = bankCardType;
    }

    public String getCvn2() {
        return cvn2;
    }

    public void setCvn2(String cvn2) {
        this.cvn2 = cvn2;
    }

    public String getPeriod() {
        return period;
    }

    public void setPeriod(String period) {
        this.period = period;
    }

    public String getDefaulted() {
        return defaulted;
    }

    public void setDefaulted(String defaulted) {
        this.defaulted = defaulted;
    }

    public Map<String, Object> validate() {
        if (isNullOrEmpty(getBankAccountName())) {
            return ResultWrap.init(Constss.FALIED, "请输入银行开户名", null);
        }
        if (isNullOrEmpty(getIdCard())) {
            return ResultWrap.init(Constss.FALIED, "请输入身份证号", null);
        }
        if (isNullOrEmpty(getPhone())) {
            return ResultWrap.init(Constss.FALIED, "请输入手机号码", null);
        }
        if (isNullOrEmpty(getBankName())) {
            return ResultWrap.init(Constss.FALIED, "请选择银行名称", null);
        }
        if (isNullOrEmpty(getCardNo())) {
            return ResultWrap.init(Constss.FALIED, "请输入银行卡号", null);
        }
        if (isNullOrEmpty(getBankSubName())) {
            return ResultWrap.init(Constss.FALIED, "请输入开户行名称", null);
        }
        if (isNullOrEmpty(getBankChannelNo())) {
            return ResultWrap.init(Constss.FALIED, "请输入银行联行号", null);
        }
        if (isNullOrEmpty(getBankCardProvince())) {
            return ResultWrap.init(Constss.FALIED, "请选择银行卡开户省", null);
        }
        if (isNullOrEmpty(getBankCardCity())) {
            return ResultWrap.init(Constss.FALIED, "请选择银行卡开户市", null);
        }
        if (Objects.equals(getBankCardType(), "2")) {
            if (isNullOrEmpty(getCvn2())) {
                return ResultWrap.init(Constss.FALIED, "请输入卡的CVN2安全码", null);
            }
            if (isNullOrEmpty(getPeriod())) {
                return ResultWrap.init(Constss.FALIED, "请选择卡的有效期", null);
            }
        }
        return null;
    }
}
